<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="時光的个人博客" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
	  <meta name="referrer" content="no-referrer" />

      <title>Docker部署chatgpt-on-wechat |  時光</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="時光" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-Docker部署chatgpt-on-wechat"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Docker部署chatgpt-on-wechat
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/12/16/Docker%E9%83%A8%E7%BD%B2chatgpt-on-wechat/" class="article-date">
  <time datetime="2023-12-16T09:54:08.942Z" itemprop="datePublished">2023-12-16</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.7k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">6 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="一、项目介绍"><a href="#一、项目介绍" class="headerlink" title="一、项目介绍"></a>一、项目介绍</h1><p><strong>chatgpt-on-wechat</strong> (cow) 项目是使用 ChatGPT 搭建的智能聊天机器人，在GPT3.5&#x2F;4.0 API 及 itchat框架的基础上实现，支持个人微信、公众号、企业微信部署，能生成文本、语音和图片，访问操作系统和互联网。</p>
<p>最新版本支持的功能如下：</p>
<ul>
<li><strong>多端部署：</strong> 可接入 个人微信、微信公众号、企业微信应用</li>
<li><strong>基础对话：</strong> 私聊及群聊的消息智能回复，支持多轮会话上下文记忆，支持 GPT-3, GPT-3.5, GPT-4, 文心一言模型</li>
<li><strong>语音识别：</strong> 可识别语音消息，通过文字或语音回复，支持 azure, baidu, google, openai 等多种语音模型</li>
<li><strong>图片生成：</strong> 支持图片生成 和 图生图（如照片修复），可选择 Dell-E, stable diffusion, replicate, Midjourney 模型</li>
<li><strong>丰富插件：</strong> 支持个性化插件扩展，已实现多角色切换、文字冒险、敏感词过滤、聊天记录总结等插件</li>
<li><strong>Tool工具：</strong> 与操作系统和互联网交互，支持最新信息搜索、数学计算、天气和资讯查询、网页总结，基于 <a target="_blank" rel="noopener" href="https://github.com/goldfishh/chatgpt-tool-hub">chatgpt-tool-hub</a> 实现</li>
<li><strong>知识库：</strong> 通过上传知识库文件自定义专属机器人，可作为数字分身、领域知识库、智能客服使用，基于 LinkAI 实现</li>
</ul>
<p><strong>项目地址 (Github)：</strong> <a target="_blank" rel="noopener" href="https://github.com/zhayujie/chatgpt-on-wechat">https://github.com/zhayujie/chatgpt-on-wechat</a></p>
<p><strong>项目地址 (Gitee)：</strong> <a target="_blank" rel="noopener" href="https://gitee.com/zhayujie/chatgpt-on-wechat">https://gitee.com/zhayujie/chatgpt-on-wechat</a></p>
<p><strong>演示：</strong> <a target="_blank" rel="noopener" href="https://github-production-user-asset-6210df.s3.amazonaws.com/26161723/276637295-d5154020-36e3-41db-8706-40ce9f3f1b1e.mp4">视频demo</a></p>
<h1 id="二、安装步骤"><a href="#二、安装步骤" class="headerlink" title="二、安装步骤"></a>二、安装步骤</h1><h2 id="1、-下载-docker-compose-yml-文件"><a href="#1、-下载-docker-compose-yml-文件" class="headerlink" title="1、 下载 docker-compose.yml 文件"></a>1、 下载 <code>docker-compose.yml</code> 文件</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget https://open-1317903499.cos.ap-guangzhou.myqcloud.com/docker-compose.yml</span><br></pre></td></tr></table></figure>

<h2 id="2、修改docker-compose-yml文件"><a href="#2、修改docker-compose-yml文件" class="headerlink" title="2、修改docker-compose.yml文件"></a>2、修改<code>docker-compose.yml</code>文件</h2><p>需修改如下配置</p>
<p> <code>OPEN_AI_API_KEY</code> ：你的OpenAI API KEY</p>
<p> <code>SINGLE_CHAT_PREFIX </code>:  私聊时文本需要包含该前缀才能触发机器人回复</p>
<p> <code>GROUP_NAME_WHITE_LIST</code> :  开启自动回复的群名称列表</p>
<p>此处我稍微做了一些调整，修改了默认端口，分别映射到自定义端口上</p>
<p>chatgpt-on-wechat 服务默认使用以下端口：</p>
<p>80端口：用于访问 Web 界面，即聊天界面。<br>8000端口：用于与微信服务器进行通信，接收和发送消息。<br>8888端口：用于与 OpenAI GPT-3 API 进行通信，发送用户输入并接收生成的回复。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">version: &#x27;2.0&#x27;</span><br><span class="line">services:</span><br><span class="line">  chatgpt-on-wechat:</span><br><span class="line">    image: zhayujie/chatgpt-on-wechat</span><br><span class="line">    container_name: chatgpt-on-wechat</span><br><span class="line">    security_opt:</span><br><span class="line">      - seccomp:unconfined</span><br><span class="line">    ports:</span><br><span class="line">      - 8801:80</span><br><span class="line">      - 8802:8000</span><br><span class="line">      - 8803:8888</span><br><span class="line">    environment:</span><br><span class="line">      OPEN_AI_API_KEY: &#x27;xxxxxxxxxxxxx&#x27;</span><br><span class="line">      MODEL: &#x27;gpt-3.5-turbo&#x27;</span><br><span class="line">      PROXY: &#x27;&#x27;</span><br><span class="line">      SINGLE_CHAT_PREFIX: &#x27;[&quot;bot&quot;, &quot;@bot&quot;]&#x27;</span><br><span class="line">      SINGLE_CHAT_REPLY_PREFIX: &#x27;&quot;[bot] &quot;&#x27;</span><br><span class="line">      GROUP_CHAT_PREFIX: &#x27;[&quot;@bot&quot;]&#x27;</span><br><span class="line">      GROUP_NAME_WHITE_LIST: &#x27;[&quot;時光gpt测试群&quot;, &quot;ChatGPT测试群&quot;]&#x27;</span><br><span class="line">      IMAGE_CREATE_PREFIX: &#x27;[&quot;画&quot;, &quot;看&quot;, &quot;找&quot;]&#x27;</span><br><span class="line">      CONVERSATION_MAX_TOKENS: 1000</span><br><span class="line">      SPEECH_RECOGNITION: &#x27;False&#x27;</span><br><span class="line">      CHARACTER_DESC: &#x27;你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题，并且可以使用多种语言与人交流。&#x27;</span><br><span class="line">      EXPIRES_IN_SECONDS: 3600</span><br><span class="line">      USE_GLOBAL_PLUGIN_CONFIG: &#x27;True&#x27;</span><br><span class="line">      USE_LINKAI: &#x27;False&#x27;</span><br><span class="line">      LINKAI_API_KEY: &#x27;&#x27;</span><br><span class="line">      LINKAI_APP_CODE: &#x27;&#x27;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<p>更多环境变量参考以下配置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  &quot;open_ai_api_key&quot;: &quot;YOUR API KEY&quot;,                          # 填入上面创建的 OpenAI API KEY</span><br><span class="line">  &quot;model&quot;: &quot;gpt-3.5-turbo&quot;,                                   # 模型名称, 支持 gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4, wenxin, xunfei</span><br><span class="line">  &quot;proxy&quot;: &quot;&quot;,                                                # 代理客户端的ip和端口，国内环境开启代理的需要填写该项，如 &quot;127.0.0.1:7890&quot;</span><br><span class="line">  &quot;single_chat_prefix&quot;: [&quot;bot&quot;, &quot;@bot&quot;],                      # 私聊时文本需要包含该前缀才能触发机器人回复</span><br><span class="line">  &quot;single_chat_reply_prefix&quot;: &quot;[bot] &quot;,                       # 私聊时自动回复的前缀，用于区分真人</span><br><span class="line">  &quot;group_chat_prefix&quot;: [&quot;@bot&quot;],                              # 群聊时包含该前缀则会触发机器人回复</span><br><span class="line">  &quot;group_name_white_list&quot;: [&quot;ChatGPT测试群&quot;, &quot;ChatGPT测试群2&quot;], # 开启自动回复的群名称列表</span><br><span class="line">  &quot;group_chat_in_one_session&quot;: [&quot;ChatGPT测试群&quot;],              # 支持会话上下文共享的群名称  </span><br><span class="line">  &quot;image_create_prefix&quot;: [&quot;画&quot;, &quot;看&quot;, &quot;找&quot;],                   # 开启图片回复的前缀</span><br><span class="line">  &quot;conversation_max_tokens&quot;: 1000,                            # 支持上下文记忆的最多字符数</span><br><span class="line">  &quot;speech_recognition&quot;: false,                                # 是否开启语音识别</span><br><span class="line">  &quot;group_speech_recognition&quot;: false,                          # 是否开启群组语音识别</span><br><span class="line">  &quot;use_azure_chatgpt&quot;: false,                                 # 是否使用Azure ChatGPT service代替openai ChatGPT service. 当设置为true时需要设置 open_ai_api_base，如 https://xxx.openai.azure.com/</span><br><span class="line">  &quot;azure_deployment_id&quot;: &quot;&quot;,                                  # 采用Azure ChatGPT时，模型部署名称</span><br><span class="line">  &quot;azure_api_version&quot;: &quot;&quot;,                                    # 采用Azure ChatGPT时，API版本</span><br><span class="line">  &quot;character_desc&quot;: &quot;你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题，并且可以使用多种语言与人交流。&quot;,  # 人格描述</span><br><span class="line">  # 订阅消息，公众号和企业微信channel中请填写，当被订阅时会自动回复，可使用特殊占位符。目前支持的占位符有&#123;trigger_prefix&#125;，在程序中它会自动替换成bot的触发词。</span><br><span class="line">  &quot;subscribe_msg&quot;: &quot;感谢您的关注！\n这里是ChatGPT，可以自由对话。\n支持语音对话。\n支持图片输出，画字开头的消息将按要求创作图片。\n支持角色扮演和文字冒险等丰富插件。\n输入&#123;trigger_prefix&#125;#help 查看详细指令。&quot;,</span><br><span class="line">  &quot;use_linkai&quot;: false,                                        # 是否使用LinkAI接口，默认关闭，开启后可国内访问，使用知识库和MJ</span><br><span class="line">  &quot;linkai_api_key&quot;: &quot;&quot;,                                       # LinkAI Api Key</span><br><span class="line">  &quot;linkai_app_code&quot;: &quot;&quot;                                       # LinkAI 应用code</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="3、启动容器"><a href="#3、启动容器" class="headerlink" title="3、启动容器"></a>3、启动容器</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker compose up -d</span><br></pre></td></tr></table></figure>

<p>运行 <code>docker ps</code> 能查看到 NAMES 为 <code>chatgpt-on-wechat</code> 的容器即表示运行成功</p>
<p>最后运行以下命令可查看容器运行日志，扫描日志中的二维码即可完成登录：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker logs -f chatgpt-on-wechat</span><br></pre></td></tr></table></figure>

<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216181255113-1716560990.png" alt="image-20231216181256504"></p>
<h2 id="4、如何使用"><a href="#4、如何使用" class="headerlink" title="4、如何使用"></a>4、如何使用</h2><p>成功运行之后日志中会输出 “Start auto replying”，这表示你用于扫码登录的账号已经变身为机器人了，让你的好友给你发消息 或在群聊@你 都会触发自动回复，效果如下图：</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216180844935-1511805991.png" alt="image-20231216180846189"></p>
<h2 id="5、停止容器"><a href="#5、停止容器" class="headerlink" title="5、停止容器"></a>5、停止容器</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker compose down</span><br></pre></td></tr></table></figure>

<p>注意：如果修改了 <code>docker-compose.yml</code> 中的配置，需要关闭容器后再重新启动才能生效，只执行 <code>docker restart</code> 是不起作用的。</p>
<h2 id="6、常见问题"><a href="#6、常见问题" class="headerlink" title="6、常见问题"></a>6、常见问题</h2><ol>
<li>如果发送消息没有回复，对于私聊场景确认下消息是否携带了触发词，对应配置 <code>single_chat_prefix</code>，对于群聊场景要确认该群名称是否配置在群组白名单 (<code>group_name_white_list</code>) 中。</li>
<li>如果机器人回复 “我现在有点累了” 或 “我连接不到你的网络” 等，一般是访问openAI接口失败，需查看日志中的具体报错信息来定位，可能是网络不通、openAI账号额度不足、访问频率超限等原因。</li>
<li>可能存在一定账号被限制的风险，建议仅用于技术研究或娱乐，不要过高频率使用。</li>
</ol>
<p>常见问题查看 <a target="_blank" rel="noopener" href="https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs">FAQs</a>，或直接与 <a target="_blank" rel="noopener" href="https://link-ai.tech/app/Kv2fXJcH">在线项目小助手</a> 对话。</p>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          Donate
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2023/12/16/Docker%E9%83%A8%E7%BD%B2chatgpt-on-wechat/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ChatGPT/" rel="tag">ChatGPT</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Docker/" rel="tag">Docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Wechat/" rel="tag">Wechat</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2023/12/17/Docker%E9%83%A8%E7%BD%B2%E5%9C%A8%E7%BA%BF%E9%9F%B3%E4%B9%90%E6%9C%8D%E5%8A%A1Melody/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Docker部署在线音乐服务Melody
          
        </div>
      </a>
    
    
      <a href="/2023/12/16/%E6%90%AD%E5%BB%BADocker%E5%8F%AF%E8%A7%86%E5%8C%96%E9%9D%A2%E6%9D%BFPortainer/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">搭建Docker可视化面板Portainer</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.staticfile.org/valine/1.4.16/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "dx3B54wOwhi75vxC2IAZagtg-gzGzoHsz",
    app_key: "m4k2fhnFa1iPI4vbofHqMY5X",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
  
   
    <script src="https://cdn.staticfile.org/twikoo/1.4.18/twikoo.all.min.js"></script>
    <div id="twikoo" class="twikoo"></div>
    <script>
        twikoo.init({
            envId: ""
        })
    </script>
 
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023
        <i class="ri-heart-fill heart_icon"></i> Shiguang
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="時光"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>